<#import "../_layout.ftl" as layout>
${Html.s("pagetitle","编辑前端脚本版本")}
<@layout._layout>
    <script src="/content/ace-src-min-noconflict/ace.js"></script>
    <script src="/content/ace-src-min-noconflict/ext-language_tools.js"></script>
    <script src="/content/js/myAce.js"></script>
    <div class="head">
        <div class="title">
            编辑前端脚本版本 ${Html.help("编辑前端脚本版本")}
        </div>
    </div>
    <div>
        <ul class="mydetail">
            <li>
                <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">采集核心脚本</a></li>
                        <li><a href="#tabs-2">采集工具脚本</a></li>
                    </ul>
                    <div id="tabs-1">
                        <textarea id="main_script" name="main_script"  style="width: 90%;"></textarea>
                        <input id="hd_main_script" type="hidden" value="${model.main_script!?html}">
                    </div>
                    <div id="tabs-2">
                        <textarea id="tool_script" name="tool_script"  style="width: 90%;"></textarea>
                        <input id="hd_tool_script" type="hidden" value="${model.tool_script!?html}">
                    </div>
                </div>
            </li>
            <li>
                <label>版本号</label>
                <input class="mylongtext" type="text" id="version_name" name="version_name" value="${model.version_name!}" />
            </li>
            <li>
                <label>变更记录</label>
                <input class="mylongtext" type="text" id="remark" name="remark" value="${model.remark!}" />
            </li>
            <li>
                <input type="button" class="btn1" style="" value="保存" onclick="return save()" />
            </li>
        </ul>
    </div>
    <script type="text/javascript">
        var js_main_script;
        var js_tool_script;
        $( function() {
            $( "#tabs").tabs();
            js_main_script=bindAce("main_script",$("#hd_main_script").val());
            bindAppAutocompletion(js_main_script);
            js_tool_script=bindAce("tool_script",$("#hd_tool_script").val());
            bindAppAutocompletion(js_tool_script);
        } );
        function save()
        {
            $.post("/frontmetric/save",
                {
                    "id": ${id!"0"},
                    "version_name": $("#version_name").val(),
                    "remark": $("#remark").val(),
                    "main_script": js_main_script.getValue(),
                    "tool_script":js_tool_script.getValue()
                },
                function (data) {
                    if (data.code < 0) {
                        alert(data.message);
                    } else {
                        window.location = '/frontmetric/index';
                    }
                }, "json");
        }

    </script>
</@layout._layout>